@extends('admin.main')
@section('head')
    <style> .example-img a{
            color: #ffffff;
        }
        .example-img a:hover {
            text-decoration: none;
        }
        .explanation {
            color: #2CBCA3;
            background-color: #EDFBF8;
            display: block;
            width: 99%;
            height: 100%;
            padding: 6px 9px;
            border-radius: 5px;
            position: relative;
            overflow: hidden;
        }
        .explanation .title {
            white-space: nowrap;
            margin-bottom: 8px;
            position: relative;
            cursor: pointer;
        }
        i.fa {
            font-size: 14px;
            vertical-align: middle;
            margin-right: 4px;
        }
        .fa {
            display: inline-block;
            font: normal normal normal 14px/1 FontAwesome;
            font-size: inherit;
            text-rendering: auto;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
        }
        .explanation .title h4 {
            font-size: 14px;
            font-weight: normal;
            line-height: 20px;
            height: 20px;
            display: inline-block;
        }
        .explanation ul {
            color: #748A8F;
            margin-left: 10px;
        }
        .explanation li {
            line-height: 20px;
            background: url(/admin/images/macro_arrow.gif) no-repeat 0 10px;
            padding-left: 10px;
            margin-bottom: 4px;
            /*color: orange;*/
            text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
        }
    </style>
@endsection
@section('body')
    <div class="main-title">
        <h2>代客下单 ({{$shop['shop_name']}})</h2>
    </div>
    <div class="tab-wrap">
        <div class="tab-content">
            <div class="explanation" id="explanation" style="color: orange; background-color: wheat; width: 99%; height: 100%;">
                <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o" style="background: url(/admin/images/dengpao.png)"></i>
                    <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
                    <span id="explanationZoom" title="收起提示" style="display: block;"></span> </div>
                <ul>
                    <li style="color: red">下单选择商品数量，有对应水票的会自动扣减水票，无对应水票或水票余额不足，则自动转为货到付款</li>
                </ul>
            </div>
            <br>
            <form action="" method="post" class="form-horizontal">
                <div class="form-item">
                    <label class="item-label">
                        客户名称：<span class="check-tips"><input type="text" name="buyer_name" class="text input-small" value="{{isset($member['address']['name']) ? $member['address']['name'] : ''}}"></span>
                    </label>
                </div>
                <div class="form-item">
                    <label class="item-label">
                        客户电话：<span class="check-tips"><input type="text" name="mobile" class="text input-small" value="{{isset($member['address']['mobile']) ? $member['address']['mobile'] : ''}}"></span>
                    </label>
                </div>
                <div class="form-item">
                    <label class="item-label">
                        客户地址：<span class="check-tips"><input type="text" name="buyer_address" class="text input-large" value="{{isset($member['address']['area_info']) ? $member['address']['area_info'].' '.$member['address']['address'] : ''}}"></span>
                    </label>
                </div>
                <div class="form-item">
                    <label class="item-label">
                        单位名称：<span class="check-tips">{{isset($member['address']['company_name']) ? $member['address']['company_name'] : ''}}</span>
                    </label>
                </div>
                <div class="form-item">
                    <label class="item-label">
                        商品名称：
                            <span class="check-tips">
                                <select name="goods_id" id="goods_id">
                                     @if(count($goodsList))
                                        @foreach($goodsList as $v)
                                            @if(isset($v['bill']))
                                                <option style="color:red" value="{{$v['id']}}">{{$v['goods_name']}} 【 余票: {{$v['bill']['rest_num']}} 】</option>
                                            @else
                                                <option value="{{$v['id']}}"> {{$v['goods_name']}}</option>
                                            @endif
                                        @endforeach
                                    @endif
                                </select>
                            </span>
                    </label>
                </div>
                <div class="form-item">
                    <label class="item-label">
                        商品数量：
                            <span class="check-tips">
                                <input type="text" name="goods_num" class="text input-small" value="1">
                            </span>
                    </label>
                </div>
                <div class="form-item">
                    <label class="item-label">
                        订单金额：
                            <span class="check-tips">
                                <input type="text" name="money" class="text input-small" value="0">
                            </span>
                    </label>
                </div>
                <div class="form-item">
                    <label class="item-label">
                        备注说明：
                            <span class="check-tips">
                                <input type="text" name="description" class="text input-large" value="">
                            </span>
                    </label>
                </div>
                <div class="form-item">
                    <label class="item-label"></label>
                    <div class="controls">
                        <input type="hidden" name="mid" value="{{$member['id']}}">
                        <input type="hidden" name="shop_id" value="{{$member['shop_id']}}">
                        <input type="hidden" name="admin_id" value="{{$member['admin_id']}}">
                        <input type="hidden" name="worker_id" value="{{$member['worker_id']}}">
                        <button type="submit" class="btn submit-btn ajax-post" target-form="form-horizontal">确 定</button>
                        <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
                    </div>
                </div>

            </form>
        </div>
    </div>
@endsection

@section('script')
    <script>
        {{--var goodsData = JSON.parse('{!! json_encode($goodsList) !!}');--}}
        {{--var waterBillData = JSON.parse('{!! json_encode($waterBill) !!}');--}}
        {{--$(window).ready(function () {--}}
        {{--var shop_id = $('#shop_id').val();--}}
        {{--changeOptions(categoryData, shop_id, 'bucket_category')--}}
        {{--changeBillOptions(waterBillData, shop_id, 'waterbill_id')--}}
        {{--});--}}
        {{--function changeOptions(categoryData, shop_id, target) {--}}
        {{--var options = '';--}}
        {{--for (var i in categoryData) {--}}
        {{--if (categoryData[i].shop_id == shop_id) {--}}
        {{--options += "<option value='" + categoryData[i].bucket_category_id + "'>" + categoryData[i].category.title + "</option>";--}}
        {{--}--}}
        {{--}--}}
        {{--$("#" + target).append(options);--}}
        {{--}--}}
        {{--function changeBillOptions(waterBillData, shop_id, target) {--}}
        {{--var options = '';--}}
        {{--for (var i in waterBillData) {--}}
        {{--if (waterBillData[i].shop_id == shop_id) {--}}
        {{--options += "<option value='" + waterBillData[i].id + "'>" + waterBillData[i].goods_name + "</option>";--}}
        {{--}--}}
        {{--}--}}
        {{--$("#" + target).append(options);--}}
        {{--}--}}
        //        $('#shop_id').change(function () {
        //            var shop_id = $(this).val();
        //            $("#bucket_category").empty();
        //            $("#waterbill_category").empty();
        //            changeOptions(categoryData, shop_id, 'bucket_category')
        //            changeBillOptions(waterBillData, shop_id, 'waterbill_category')
        //        });
    </script>
@endsection
